package interfaz;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

public class InterfazAlmacen extends JPanel implements IVista{

	private JButton btnAlmacen;
	private JButton btnPedidos;
	private JPanel pnlFuncionalidad;

	/**
	 * Create the panel.
	 */
	public InterfazAlmacen() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{130, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JPanel panel = new JPanel();
		panel.setBackground(Color.WHITE);
		GridBagConstraints gbc_panel = new GridBagConstraints();
		gbc_panel.insets = new Insets(0, 0, 0, 5);
		gbc_panel.fill = GridBagConstraints.BOTH;
		gbc_panel.gridx = 0;
		gbc_panel.gridy = 0;
		add(panel, gbc_panel);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{15, 0, 15, 0};
		gbl_panel.rowHeights = new int[]{30, 0, 10, 10, 0, 0};
		gbl_panel.columnWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		
		btnAlmacen = new JButton("Almacen");
		GridBagConstraints gbc_btnAlmacen = new GridBagConstraints();
		gbc_btnAlmacen.insets = new Insets(0, 0, 5, 5);
		gbc_btnAlmacen.gridx = 1;
		gbc_btnAlmacen.gridy = 1;
		panel.add(btnAlmacen, gbc_btnAlmacen);
		
		btnPedidos = new JButton("Pedidos");
		GridBagConstraints gbc_btnPedidos = new GridBagConstraints();
		gbc_btnPedidos.insets = new Insets(0, 0, 0, 5);
		gbc_btnPedidos.gridx = 1;
		gbc_btnPedidos.gridy = 4;
		panel.add(btnPedidos, gbc_btnPedidos);
		
		pnlFuncionalidad = new JPanel();
		pnlFuncionalidad.setBackground(Color.WHITE);
		GridBagConstraints gbc_pnlFuncionalidad = new GridBagConstraints();
		gbc_pnlFuncionalidad.fill = GridBagConstraints.BOTH;
		gbc_pnlFuncionalidad.gridx = 1;
		gbc_pnlFuncionalidad.gridy = 0;
		add(pnlFuncionalidad, gbc_pnlFuncionalidad);

	}

	@Override
	public void update() {
		this.invalidate();
		this.pnlFuncionalidad.invalidate();
		this.repaint();
		this.pnlFuncionalidad.repaint();
		this.revalidate();
	}

	@Override
	public void SetVisible(boolean visible) {
		
		
	}

	@Override
	public void registerListener(ActionListener listener) {
		this.btnAlmacen.addActionListener(listener);
		this.btnPedidos.addActionListener(listener);
	}
	
	public void setPanelFuncionalidad(JPanel panelFuncionalidad) {
		this.remove(this.pnlFuncionalidad);
		
		panelFuncionalidad.setBackground(Color.WHITE);
		GridBagConstraints gbc_pnlFuncionalidad = new GridBagConstraints();
		gbc_pnlFuncionalidad.fill = GridBagConstraints.BOTH;
		gbc_pnlFuncionalidad.gridx = 1;
		gbc_pnlFuncionalidad.gridy = 0;
		add(panelFuncionalidad, gbc_pnlFuncionalidad);
		
		this.pnlFuncionalidad = panelFuncionalidad;
	}

}
